package com.Jin.dao;

import com.Jin.pojo.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import java.util.List;

@Mapper
@Repository
public interface UserDao {

    //登录，判断账号密码
    @Select("select * from users where account=#{account} and password=#{password}")
    public User selectUser(@Param("account") String account,@Param("password") String password);

    //保存用户，注册
    @Insert("insert into users(account, password, sex, name, age, address, number, identifyID, identify ) " +
            "VALUES (#{account},#{password},#{sex},#{name},#{age},#{address},#{number},#{identifyID},#{identify})")
    public int saveUser(User user);

    //更新用户信息
    @Update("update users set " +
            "account=#{account},password=#{password},sex=#{sex},name=#{name},age=#{age}," +
            "address=#{address},number=#{number},identifyID=#{identifyID},identify=#{identify} " +
            "where id=#{id}")
    public int updateUser(User user);

    //修改密码
    @Update("update users set password=#{password} where account=#{account} ")
    public int updateUserPassword(@Param("account") String account,@Param("password") String password);

    //查询用户信息
    @Select("select * from users where account=#{account}")
    public User selectUsers(String account);

    //查询所有用户信息
    @Select("select * from users")
    public List<User> selectAllUser();
}
